package com.gran.mydemo.adapters;

import com.gran.mydemo.myview.PictureUnderText;

import android.R.integer;
import android.content.Context;
import android.text.style.ImageSpan;
import android.util.Log;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.Gallery;
import android.widget.GridView;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.LinearLayout.LayoutParams;
import android.widget.Toast;

public class gridAdapter extends BaseAdapter {
	Context ctx;
	Integer imageid[];
	GridView gridv;
	public gridAdapter(Context ct,Integer image[],GridView gridv){
		ctx=ct;
		imageid=image;
		this.gridv=gridv;
	}

	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		log("getcount()="+imageid.length);
		return imageid.length;
	}

	@Override
	public Object getItem(int position) {
		log("getitem()="+position);
		return position;
	}

	@Override
	public long getItemId(int position) {
		log("getitemid()="+position);
		return position;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		log("getView()="+position);
		PictureUnderText im=new PictureUnderText(ctx);
		im.setImage(imageid[position]);
		im.setText("ͼƬ_"+position);
		android.widget.AbsListView.LayoutParams ly=new GridView.LayoutParams(220, 220);
		im.setLayoutParams(ly);
		return im;
	}
	
	
	private void log(String msg){
		Log.d("gridAdapter.java", msg);
	}

}
